package com.chaos.system.controller;


import com.chaos.framework.model.dto.ID;
import com.chaos.framework.model.dto.page.PageQueryDto;
import com.chaos.framework.model.dto.result.data.BooleanResult;
import com.chaos.framework.model.dto.result.data.DataResult;
import com.chaos.framework.model.dto.result.list.ListResult;
import com.chaos.framework.model.dto.result.page.PageResult;
import com.chaos.framework.starter.base.BaseController;
import com.chaos.system.data.RbacPermissionData;
import com.chaos.system.service.RbacPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

/**
 * @author Jacky.Cui
 * @since 2024-11-13
 */
@Slf4j
@RestController
@Api(tags = "权限表")
@RequestMapping("/rbacPermission")
public class RbacPermissionController extends BaseController<RbacPermissionData> {
    @Resource
    private RbacPermissionService rbacPermissionService;

    @PostMapping("/one.admin")
    @ApiOperation(value = "权限表详情", httpMethod = "POST")
    public DataResult<RbacPermissionData> one(@RequestBody ID data) {
        return dataResult(rbacPermissionService.selectByID(data));
    }

    @PostMapping("/list.admin")
    @ApiOperation(value = "权限表列表", httpMethod = "POST")
    public ListResult<RbacPermissionData> list(@RequestBody RbacPermissionData data) {
        return listResult(rbacPermissionService.selectByData(data));
    }

    @PostMapping("/page.admin")
    @ApiOperation(value = "权限表分页", httpMethod = "POST")
    public PageResult<RbacPermissionData> page(@RequestBody PageQueryDto<RbacPermissionData> data) {
        return pageResult(rbacPermissionService.selectByPage(data));
    }

    @PostMapping("/add.admin")
    @ApiOperation(value = "新增权限表", httpMethod = "POST")
    public DataResult<ID> add(@RequestBody RbacPermissionData data) {
        return dataResult(rbacPermissionService.insertModel(data));
    }

    @PostMapping("/update.admin")
    @ApiOperation(value = "编辑权限表", httpMethod = "POST")
    public BooleanResult update(@RequestBody RbacPermissionData data) {
        return booleanResult(rbacPermissionService.updateModelByID(data));
    }

    @PostMapping("/delete.admin")
    @ApiOperation(value = "删除权限表", httpMethod = "POST")
    public BooleanResult delete(@RequestBody ID data) {
        return booleanResult(rbacPermissionService.deleteModel(data));
    }

}
